package 力扣日常刷题.木22一月.第05天0113;

/**
 * @author 帅小伙
 * @date 2022/1/13
 * @description
 */
public class Demo01每日一题简单至少是其他数字两倍的最大数 {


    public int dominantIndex(int[] nums) {
        int a = Integer.MIN_VALUE, b = Integer.MIN_VALUE;
        int index = -1;

        for (int i = 0; i < nums.length; i++) {
            if (a < nums[i]) {
                b = a;
                a = nums[i];
                index = i;
            } else if (b < nums[i]) {
                b = nums[i];
            }
        }
        return a >= b ? index : -1;
    }

}
